<?php $view->extend('::layout.html.php') ?>

<?php $view['slots']->start('_content') ?>
<div class="contenu">
<?php echo $view->render(
            'LEAUserBundle:Default:respMenu.html.php',
            array('user' => $user,
					 'refYear' => $refYear,
					 'arrayProf' => $arrayProf,
					 'arraySecr' => $arraySecr,
					 'arrayResp' => $arrayResp,
					 'menuProf' => $menuProf,
					 'menuSecr' => $menuSecr,
					 'menuResp' => $menuResp)
        ) ?>

        <div id="cadre_0" class="contenu-item2 on"><br/>
		<?php echo $view['form']->widget($listeSituationEtu)  ?>
		<?php //echo $view['form']->widget($listeTuteur)  ?>
		<?php echo $view['form']->widget($listeFormation)  ?>

<?php $i = 0 ?>
            <a onClick="javascript:checkAll('actionForm','selection[]',true);"><font style="color:blue; text-decoration:underline;">Tous</font></a>
            <a onClick="javascript:checkAll('actionForm','selection[]',false);"><font style="color:blue; text-decoration:underline;">Aucun</font></a>





    <div class="container-fluid">
     <table id="tableau_triable" class="tablesorter" border="0" cellpadding="1" cellspacing="1" width=100%>
                <thead><tr class="hidden-xs">
                        <th></th>
                        <th>Nom</th>
                        <th>Prenom</th>
                        <th>Formation</th>
                        <th>Ville</th>
                        <th>Entreprise</th>
                        <th>Référent</th>
                        <th>Tuteur <br/> (nb. notifs)</th>
                        <th width="200pt"><div id="head"><!--for backward comp--></div><!--a href="#" onClick="javascript:openAll(layer);">details</a--></th>
                    </tr><tr class="visible-xs">
                        <th></th>
                        <th>Nom</th>
                        <th>Prenom</th>
                        <th>Formation</th>
                    </tr><tr class="visible-xs">
                        <th>Ville</th>
                        <th>Entreprise</th>
                        <th>Référent</th>
                        <th>Tuteur <br/> (nb. notifs)</th>
                    </tr>
                </thead>
                <tbody>
 <?php
                    $missingMix = "";
                    $emailsULille1 = "";
                    $missingULille1 = "";
                    $emailsMix = "";
                    $missing ="";
                    do {

                        $row = $listeEtud->fetch() ;

                        if (!$row)
                            break;

                        $altCle = $row['alternanceCle'];
                        $tuteur = $row['tuteurRef'];
/*
                        if ($tuteur !== $tuteurParam && $tuteurParam !== "%")
                            continue;

                        if ($situationEtud === "AVEC_TUTEUR"
                                && (strstr($tuteur, $tuteurParam) === FALSE && ($tuteurParam !== "%") || (strcmp($tuteur, "aucun") == 0)))
                            continue;
                        if ($situationEtud === "SANS_TUTEUR" && strcmp($tuteur, "aucun") != 0)
                            continue;
*/
                        $entreprise = $row['entreprise'];

/*
                        if ($situationEtud === "AVEC_ENTR" && $entreprise === "__sans entreprise__")
                            continue;
                        if ($situationEtud === "SANS_ENTR" && $entreprise !== "__sans entreprise__")
                            continue;
*/
                        $et_pn = $row['prenom'] . " " . $row['nom'];
                        $emails ="" ;
                        if ($row['mail_etu']) {
                            $emails = $emails . ", " . $row['mail_etu'];
                        } else {
                            $missing.=", " . $et_pn;
                        }
                        if ($row['mailLille1']) {
                            $emailsULille1.=", " . $row['mailLille1'];
                        } else
                        $missingULille1.=", " . $et_pn;
                        if ($row['mailLille1']) {
                            $emailsMix.=", " . $row['mailLille1'];
                        } else
                        if ($row['mail_etu']) {
                            $emailsMix.=", " . $row['mail_etu'];
                        } else {
                            $missingMix.=", " . $et_pn;
                        }


                        $notifAttribTuteur = $row['notif'];
                        $nom = $row['nom'];
                        $prenom = $row['prenom'];
                        $formation = $row['formation'];
                        $ville = $row['ville'];
                        $referent = $row['referent'];
                        $motscles = $row['motscles'];

                        $missions = $row['mission'];
                        $services = $row['service'];
                        $clients = $row['client'];
                        $envTech = $row['env'];

                       /* echo "<td><input type='checkbox' id=\"chbox_$i\" name='selection[]' value='";
                        echo $row['nom'], "'/>";
                        echo "</td>";

                        echo "<td>&nbsp;", $nom, "</td>";
                        echo "<td>&nbsp;", $prenom, "</td>";

                        echo "<td>&nbsp;", $formation, "</td>";

                        echo "<td>&nbsp;", $ville, " </td>";
                        echo "<td>&nbsp;", substr($entreprise,0,20), " </td>";
                        echo "<td>&nbsp;", $referent, " </td>";
                        echo "<td></td>" ;*/
                        echo "<tr class='hidden-xs'";
                        if ($i%2)
                            echo " style='background:#ccc'";
                        echo ">";
                       echo "<td><input type='checkbox' id=\"chbox_$i\" name='selection[]'/>";
                        echo "</td>";

                        echo "<td>&nbsp;", $nom, "</td>";
                        echo "<td>&nbsp;", $prenom, "</td>";

                        echo "<td>&nbsp;", $formation, "</td>";

                        echo "<td>&nbsp;", $ville, " </td>";
                        echo "<td>&nbsp;", substr($entreprise,0,20), " </td>";
                        echo "<td>&nbsp;", $referent, " </td>";
                        echo "<td class='small'>&nbsp;", $tuteur, "(",$notifAttribTuteur,")", "</td>";

                        echo "<td>";
                        ?><center>
                        <div class="btn-group">
                            <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                              <span class="glyphicon glyphicon-cog"></span>

                              <span class="caret"></span>
                            </button>
                            <ul class="dropdown-menu">
                              <?php
                              	$i = 0 ;
                              	$space = array(4,6,8,10,11,12) ;
                              	foreach($listeAction as $value){
                              		echo "<li><a href='". $view['router']->generate('lea_etud_maj_info', array('user' => strtolower($prenom).".".strtolower($nom)))."' class='list-group-item'>".$value."</a></li>" ;
                              		$i ++ ;
                              		if(in_array($i, $space)){
                              			echo "<li class='divider'></li>" ;
                              		}

                              	}
                             ?>
                            </ul>
                        </div>
                        </center>
                        <?

                        echo "</td>";
                        echo "</tr>";

                        echo "<tr class='visible-xs lc'";

                        if ($i%2)
                            echo " style='background:#ccc'";
                        echo ">";
                       echo "<td class='small'><input type='checkbox' id=\"chbox_$i\" name='selection[]'/>";
                        echo "</td>";

                        echo "<td class='small'>&nbsp;", $nom, "</td>";
                        echo "<td class='small'>&nbsp;", $prenom, "</td>";

                        echo "<td class='small'>&nbsp;", $formation, "</td>";
                        echo "</tr>";
                        echo "<tr class='visible-xs lc'";
                        if ($i%2)
                            echo " style='background:#ccc'";
                        echo ">";

                        echo "<td>&nbsp;", $ville, " </td>";
                        echo "<td class='small'>&nbsp;", substr($entreprise,0,20), " </td>";
                        echo "<td class='small'>&nbsp;", $referent, " </td>";
                        echo "<td class='small'>&nbsp;", $tuteur, "(",$notifAttribTuteur,")", "</td>";


                       // $divs = $divs . ",'td" . $i . "'";
                        //echo "<td>";

                /*        echo "<select name=\"a_" . str_replace('.', '_', $altCle) . "\>";
                        echo $selectString;
                        echo "</select>";

                         echo "</td>";
                        echo "</tr>";*/

                        $i = $i + 1;
                    } while ($row);
                    $nbDivs = $i;
                    ?>
                </tbody>
            </table>
</div>
</div>


            <a onClick="javascript:checkAll('actionForm','selection[]',true);"><font style="color:blue; text-decoration:underline;">Tous</font></a>
            <a onClick="javascript:checkAll('actionForm','selection[]',false);"><font style="color:blue; text-decoration:underline;">Aucun</font></a>
            <br/>

</div>
<script type="text/javascript">
(function() {

    // how many milliseconds is a long press?
    var longpress = 1000;
    // holds the start time
    var start;

    jQuery( ".lc" ).on( 'mousedown', function( e ) {
        start = new Date().getTime();
    } );

    jQuery( ".lc" ).on( 'mouseleave', function( e ) {
        start = 0;
    } );

    jQuery( ".lc" ).on( 'mouseup', function( e ) {
        if ( new Date().getTime() >= ( start + longpress )  ) {
            $('.bs-example-modal-lg').modal('show');
        }
        else {
            $('.bs-example-modal-lg').modal('show');
        }
    } );

}());
</script>

<div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="myModalLabel">Actions</h4>
      </div>
      <div class="modal-body">
        <div class="list-group">
          <?php
                $i = 0 ;
				$space = array(4,6,8,10,11,12) ;
                foreach($listeAction as $value){
                    echo "<li><a href='#' class='list-group-item'>".$value."</a></li>" ;
                    $i ++ ;
                    if(in_array($i, $space)){
                        echo "<li class='divider'></li>" ;
					}
                }
			?>
        </div>

      </div>
    </div>
  </div>
</div>